package com.rmfyzxfw.caseprocess.boot.xss;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.apache.commons.text.StringEscapeUtils;

import java.io.IOException;
/**
 * @description: 对前端传递的数据格式为json格式的参数进行特殊字符转义
 * @author: Lixx
 * @time: 2023/2/4 15:43
 */
public class XssStringJsonDeSerializer extends JsonDeserializer<String> {

    @Override
    public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
        //对json格式的参数值进行转义
        return StringEscapeUtils.escapeHtml4(jsonParser.getText());
    }
}

